<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>三3三博客社区</title>
    <link rel="icon" href="../../images/icon.jpg" sizes="32x32">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="滚动条, scrollbar, 页面底部, 聊天窗口, " />
    <meta name="description" content="有些时候（如开发聊天程序），我们需要将将滚动条（scrollbar）保持在最底部，比如聊天窗口，最新发出和收到的信息要显示在最 下方，如果要看到最下方的内容，就必须保证滚动条保持在最底部。" />
    <title>将滚动条（scrollbar）保持在最底部的方法 - 滚动条, scrollbar, 页面底部, 聊天窗口, </title>
    <style type="text/css">
        .bell-circleGrey {
            border-radius: 50%;
            height: 16px;
            width: 16px;
            display: inline-block;
            background: #c3bebe;
            vertical-align: top;
        }
        .bell-circleRed {
            border-radius: 50%;
            height: 16px;
            width: 16px;
            display: inline-block;
            background: red;
            vertical-align: top;
        }
        .bell-number {
            display: block;
            color: #FFFFFF;
            height: 16px;
            line-height: 16px;
            text-align: center;
            font-size:6px;
        }
    </style>
</head>
<body>
<div class="bell-wrapper" style="position:relative;" @click="handleNotic">
    <img src="../../../assets/notice.png" style="width:24px;margin-bottom:-8px;">
    <span v-if="unreadMessageCount > 0" class="bell-circleRed" style="position:absolute;top:7px; left:14px;">
          <span class="bell-number">{{ unreadMessageCount }}</span>
        　<span v-else class="bell-circleGrey" style="position:absolute;top:7px; left:14px;">
            <span class="bell-number">{{ unreadMessageCount }}</span>
        </span>
    </span>
</div>
</body>
<script>
    import {
        unreadMessage // 查询消息未读数量
    } from '@/api/personalCenter'

    export default {
        data() {
            return {
                timer: '',
                unreadMessageCount: 0 // 未读消息
            }
        },

        created() {
            this.getUnreadMessage()
        },
        mounted() {
            // 调用定时任务实时获取未读消息
            this.timer = setInterval(this.getUnreadMessage, 30000)
        },
        methods: {

            // 查询未读消息数量
            getUnreadMessage() {
                unreadMessage().then((res) => {
                    if (res.data.code === '000') {
                        this.unreadMessageCount = res.data.content
                        console.log(res)
                    }
                }).catch((err) => {
                    console.log(err)
                })
            },
            handleNotic() {
                this.$router.push('/personalCenterManagement/information')
            }
        }
    }

</html>